
# coding:utf-8
from multiprocessing import TimeoutError
from nose_ittr import IttrMultiplier,ittr
from nose.tools import assert_equal, assert_not_equal
from util.excelUtil import getRowsData
from util.commonLog import commonLog
import logging
import os

from util.requestUtil import sendGetRequest

curr_dir = os.path.dirname(os.path.abspath(__file__))
print os.path.abspath(__file__)  # 输出当前所在文件文件名
print curr_dir                   # 输出当前所在文件的所在目录名

class TestFunc(object):

    def __init__(self):
        logging.setLoggerClass(commonLog)
        self.logger = logging.getLogger(__name__)
        self.logger.info(__name__)

    __metaclass__ = IttrMultiplier

    def setup(self):
        self.logger.info("========setUp========")


    def teardown(self):
        self.logger.info("========setUp========")

    data = getRowsData('3335.xls', 'excel1', 0)
    info_data = getRowsData('1111.xls', 'excel1',1)

    @ittr(userId=data, info=info_data)
    def test1(self):

        self.logger.info(self.data)
        host = "http://api.geinihua.com/order2"
        path = "/user/userInfoTuomin"
        userId = self.data
        parmas = {"userId": userId}
        self.logger.info(parmas)
        url = host + path
        headers = {"User-Agent": "Chrome"}
        response = sendGetRequest(url, headers=headers, params=parmas)
        target = response["code"]
        # 断言期望值
        assert target == 1, u'target: {}, not equal to expectCode: {}'.format(target, 1)

